package com.cq.hd.common.enums.biz;

import lombok.Getter;

/**
 * @description: 交易状态：1-待支付，2-支付成功，3-支付失败，4-退款中，5-退款成功，6-退款失败
 * @author: mYunYu
 * @date: 2021/8/23 14:28
 * @version: v1.0
 */
public enum OrderPayRecordTradeStateEnum {

    NO_PAY(1, "待支付"),
    PAY_SUCCESS(2, "支付成功"),
    PAY_FAIL(3, "支付失败"),
    REFUNDING(4, "退款中"),
    REFUND_SUCCESS(5, "退款成功"),
    REFUND_FAIL(6, "退款失败"),
    ;

    @Getter
    private final Integer value;

    @Getter
    private final String name;

    OrderPayRecordTradeStateEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public static OrderPayRecordTradeStateEnum typeOf(Integer value) {
        OrderPayRecordTradeStateEnum[] values = OrderPayRecordTradeStateEnum.values();
        for (OrderPayRecordTradeStateEnum v : values) {
            if (v.value.equals(value)) {
                return v;
            }
        }
        return null;
    }

    public static OrderPayRecordTradeStateEnum typeOf(String name) {
        OrderPayRecordTradeStateEnum[] values = OrderPayRecordTradeStateEnum.values();
        for (OrderPayRecordTradeStateEnum v : values) {
            if (v.name.equals(name)) {
                return v;
            }
        }
        return null;
    }

}
